<@t.plat_body pageid="clazzs">
<script type="text/javascript" src="${base}/js/plugins/uploaders/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/uploaders/plupload/plupload.queue.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/uploaders/plupload/i18n/zh_CN.js"></script>
<style>
    .plupload_filelist:empty:after, .plupload_filelist li.plupload_droptext:after{
        content:'把文件拖到这里'
    }
</style>

<div class="panel border-top-primary" style="margin: 0">
    <div class="page-header" style="margin: 0">
        <div class="breadcrumb-line breadcrumb-line-wide border-top-primary">
            <ul class="breadcrumb">
                <li><a href="${base}/plat/info/clazzs"><i class="icon-arrow-left52 position-left"></i>班级管理</a></li>
                <li class="active">批量导入</li>
            </ul>
        </div>
    </div>
</div>


<div class="content">

    <div class="panel panel-flat">
        <div class="panel-heading">
            <h5 class="panel-title">批量导入</h5>
            <div class="heading-elements">
                <a style="margin-left: 2px" class="btn btn-danger btn-xs btn-outline" target="_blank" download="class_template.xlsx" href="${base}/res/class_template.xlsx">模板下载</a>
            </div>
        </div>


        <div class="panel-body">
            <div>
                <div class="file-uploader"></div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        var data={};
        var index=0;
        data.firstRow=3;
        data.name=index++;//姓名
        data.graduation=index++;//是否毕业
        plupload.addI18n({
            'Add Files': '选择文件',
            'Start Upload': '开始导入'
        });

        $(".file-uploader").pluploadQueue({
            runtimes: 'html5, html4, Flash, Silverlight',
            url: '${base}/pl/info/import_class',
            chunk_size: '300Kb',
            unique_names: true,
            multi_selection:false,
            filters: {
                max_file_size: '100mb',
                mime_types: [{
                    title: "Excel文件",
                    extensions: "xls,xlsx"
                }]
            },
            multipart_params:data,
            init:{
                FilesAdded : function(uploader, file){
                    if(uploader.files.length>1) { // 最多上传3张图
                        uploader.removeFile(uploader.files[uploader.files.length-1]);
                        return;
                    }
                },
                FileUploaded : function(up, file, info) {//文件上传完毕触发
                    var response = $.parseJSON(info.response);
                    if(response.code==0){
                        alertError('操作成功');
                    }else{
                        if(response.code==4000){
                            var l=parent.layer;
                            if(!l){
                                l=layer;
                            }
                            l.msg(response.message+'，点击下载详情<a href="${base}/pl/info/download/batch/result" style="color: #4fc3f7;font-style: normal" id="saveys-number">下载</a><button type="button" onclick="layer_close_all()">关闭</button>', {
                                icon: 16
                                ,time:1000000000
                                ,shade: [0.3,'#000000']
                            });

                        }else{
                            alertError('文件上传失败');
                        }

                    }

                }
            }
        });


    });




</script>
</@t.plat_body>